from typing import List

from pydantic import Field

from server.schemas.BaseSchema import BaseSchema


class AddMenuSchema(BaseSchema):
    """
    添加菜单传参模型
    """
    name: str = Field(..., min_length=3, max_length=100)
    permission: str = Field(None, min_length=3, max_length=100)
    path: str = Field(None)
    icon: str = Field(None)
    order: int = Field(None)
    parent_id: str = Field(None)
    is_active: bool = True
    is_deleted: bool = False


class UpdateMenuSchema(BaseSchema):
    """
    更新菜单传参模型
    """
    id: str = Field(..., min_length=18)
    name: str = Field(None, min_length=3, max_length=100)
    path: str = Field(None)
    icon: str = Field(None)
    order: int = Field(None)
    is_active: bool = True
    is_deleted: bool = False


class DeleteMenuSchema(BaseSchema):
    """
    删除菜单传参模型
    """
    id: str = Field(..., min_length=18)




class MenuAlreadyExists(BaseSchema):
    """
    菜单已存在响应模型
    """
    code: int = 1400
    msg: str = "菜单已存在"


class MenuResponseList(BaseSchema):
    """
    返回菜单树模型
    """
    id: str
    name: str
    path: str
    icon: str
    order: int
    is_active: bool
    is_show: bool
    permission: str
    children: List['MenuResponseList']







